"""
MEMESA-TOOLS
============
Model preparation, vertex enumeration and vertex analysis tools developed as
part of the MEMESA project. 

    Copyright (C) 2009-2012 Brett G. Olivier

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>

Author: Brett G. Olivier
Contact email: bgoli@users.sourceforge.net

"""

def Define_model_template():
    model_name = 'The model name'
    
    Reactions = {'R01' : {'id' : 'R01', 'reversible' : False, 'reagents' : [(-1, 'X0'), (1, 'A')], 'SUBSYSTEM' : ''}
                }
                
    Species = { 'X0' : {'id' : 'X0', 'boundary' : True, 'SUBSYSTEM' : ''},
                'A' : {'id' : 'A', 'boundary' : False, 'SUBSYSTEM' : 'C1'}
              }
              
    Bounds = {'R01' : {'lower' : 0, 'upper' : 1}}
    
    Objective_function = {'obj1' : {'id' : 'obj1', 'flux' : 'R01', 'coefficient' : 1, 'sense' : 'Maximize', 'active' : True}}
    
    print '\nModel name:', model_name
    print '\nReactions:'
    print Reactions
    print '\nSpecies:'
    print Species
    print '\nBounds:'
    print Bounds
    print '\nObjective function:'
    print Objective_function
    
    return None, None, None, None, None

def Define_core_memesa_model():
    """\nOriginal core model + inefficient branch\n"""
    
    model_name = 'core_memesa_model'
    
    Reactions ={'R01' : {'id' : 'R01', 'reversible' : False, 'reagents' : [(-1, 'X'), (1, 'A')], 'SUBSYSTEM' : 'L'},
                'R02' : {'id' : 'R02', 'reversible' : True, 'reagents' : [(-1, 'A'), (1, 'B')], 'SUBSYSTEM' : 'C1'},
                'R03' : {'id' : 'R03', 'reversible' : True, 'reagents' : [(-1, 'A'), (1, 'C')], 'SUBSYSTEM' : 'C1'},
                'R04' : {'id' : 'R04', 'reversible' : True, 'reagents' : [(-1, 'C'), (1, 'B')], 'SUBSYSTEM' : 'C1'},
                'R05' : {'id' : 'R05', 'reversible' : False, 'reagents' : [(-1, 'B'), (1, 'D')], 'SUBSYSTEM' : 'L'},
                'R06' : {'id' : 'R06', 'reversible' : False, 'reagents' : [(-1, 'D'), (1, 'E')], 'SUBSYSTEM' : 'C2'},
                'R07' : {'id' : 'R07', 'reversible' : False, 'reagents' : [(-1, 'E'), (1, 'F')], 'SUBSYSTEM' : 'C2'},
                'R08' : {'id' : 'R08', 'reversible' : False, 'reagents' : [(-1, 'F'), (1, 'I')], 'SUBSYSTEM' : 'C2'},
                'R09' : {'id' : 'R09', 'reversible' : False, 'reagents' : [(-1, 'D'), (1, 'G')], 'SUBSYSTEM' : 'C2'},
                'R10' : {'id' : 'R10', 'reversible' : False, 'reagents' : [(-1, 'G'), (1, 'H')], 'SUBSYSTEM' : 'C2'},
                'R11' : {'id' : 'R11', 'reversible' : False, 'reagents' : [(-1, 'H'), (1, 'I')], 'SUBSYSTEM' : 'C2'},
                'R12' : {'id' : 'R12', 'reversible' : False, 'reagents' : [(-1, 'I'), (1, 'J')], 'SUBSYSTEM' : 'L'},
                'R13' : {'id' : 'R13', 'reversible' : False, 'reagents' : [(-1, 'J'), (1, 'K')], 'SUBSYSTEM' : 'C3'},
                'R14' : {'id' : 'R14', 'reversible' : True, 'reagents' : [(-1, 'K'), (1, 'L')], 'SUBSYSTEM' : 'C3'},
                'R15' : {'id' : 'R15', 'reversible' : False, 'reagents' : [(-1, 'L'), (1, 'Q')], 'SUBSYSTEM' : 'C3'},
                'R16' : {'id' : 'R16', 'reversible' : False, 'reagents' : [(-1, 'J'), (1, 'M')], 'SUBSYSTEM' : 'C3'},
                'R17' : {'id' : 'R17', 'reversible' : False, 'reagents' : [(-1, 'M'), (1, 'N')], 'SUBSYSTEM' : 'C3'},
                'R18' : {'id' : 'R18', 'reversible' : False, 'reagents' : [(-1, 'N'), (1, 'Q')], 'SUBSYSTEM' : 'C3'},
                'R19' : {'id' : 'R19', 'reversible' : True, 'reagents' : [(-1, 'K'), (1, 'O')], 'SUBSYSTEM' : 'C3'},
                'R20' : {'id' : 'R20', 'reversible' : True, 'reagents' : [(-1, 'O'), (1, 'P')], 'SUBSYSTEM' : 'C3'},
                'R21' : {'id' : 'R21', 'reversible' : True, 'reagents' : [(-1, 'P'), (1, 'L')], 'SUBSYSTEM' : 'C3'},
                'R22' : {'id' : 'R22', 'reversible' : False, 'reagents' : [(-1, 'Q'), (1, 'R')], 'SUBSYSTEM' : 'L'},
                'R23' : {'id' : 'R23', 'reversible' : True, 'reagents' : [(-1, 'R'), (1, 'S')], 'SUBSYSTEM' : 'C4'},
                'R24' : {'id' : 'R24', 'reversible' : False, 'reagents' : [(-1, 'R'), (1, 'S')], 'SUBSYSTEM' : 'C4'},
                'R25' : {'id' : 'R25', 'reversible' : False, 'reagents' : [(-1, 'A'), (-1, 'T'), (0.5, 'S'), (1, 'U')], 'SUBSYSTEM' : 'L'},
                'R26' : {'id' : 'R26', 'reversible' : False, 'reagents' : [(-1, 'S'), (1, 'Y')], 'SUBSYSTEM' : 'L'}
               }
               
    Species = { 'X' : {'id' : 'X', 'boundary' : True, 'SUBSYSTEM' : 'B'},
                'A' : {'id' : 'A', 'boundary' : False, 'SUBSYSTEM' : 'C1'},
                'B' : {'id' : 'B', 'boundary' : False, 'SUBSYSTEM' : 'C1'},
                'C' : {'id' : 'C', 'boundary' : False, 'SUBSYSTEM' : 'C1'},
                'D' : {'id' : 'D', 'boundary' : False, 'SUBSYSTEM' : 'C2'},
                'E' : {'id' : 'E', 'boundary' : False, 'SUBSYSTEM' : 'C2'},
                'F' : {'id' : 'F', 'boundary' : False, 'SUBSYSTEM' : 'C2'},
                'G' : {'id' : 'G', 'boundary' : False, 'SUBSYSTEM' : 'C2'},
                'H' : {'id' : 'H', 'boundary' : False, 'SUBSYSTEM' : 'C2'},
                'I' : {'id' : 'I', 'boundary' : False, 'SUBSYSTEM' : 'C2'},
                'J' : {'id' : 'J', 'boundary' : False, 'SUBSYSTEM' : 'C3'},
                'K' : {'id' : 'K', 'boundary' : False, 'SUBSYSTEM' : 'C3'},
                'L' : {'id' : 'L', 'boundary' : False, 'SUBSYSTEM' : 'C3'},
                'M' : {'id' : 'M', 'boundary' : False, 'SUBSYSTEM' : 'C3'},
                'N' : {'id' : 'N', 'boundary' : False, 'SUBSYSTEM' : 'C3'},
                'O' : {'id' : 'O', 'boundary' : False, 'SUBSYSTEM' : 'C3'},
                'P' : {'id' : 'P', 'boundary' : False, 'SUBSYSTEM' : 'C3'},
                'Q' : {'id' : 'Q', 'boundary' : False, 'SUBSYSTEM' : 'C3'},
                'R' : {'id' : 'R', 'boundary' : False, 'SUBSYSTEM' : 'C4'},
                'S' : {'id' : 'S', 'boundary' : False, 'SUBSYSTEM' : 'C4'},
                'T' : {'id' : 'T', 'boundary' : True, 'SUBSYSTEM' : 'B'},
                'U' : {'id' : 'U', 'boundary' : True, 'SUBSYSTEM' : 'B'},
                'Y' : {'id' : 'Y', 'boundary' : True, 'SUBSYSTEM' : 'B'}
              }
              
    Bounds = {'R01' : {'lower' : 0, 'upper' : 1}}
    
    Objective_function = {'objMaxJ25' : {'id' : 'objMaxJ25', 'flux' : 'R26', 'coefficient' : 1, 'sense' : 'Maximize', 'active' : True}}
    
    return model_name, Reactions, Species, Bounds, Objective_function
